package com.qidian.mes.pro.controller;

import com.qidian.mes.pojo.TechniqueMat;
import com.qidian.mes.pro.service.MatService;
import com.qidian.mes.util.dot.PagerDTO;
import com.qidian.mes.util.pojo.QdResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author dqy
 * @Description
 * @Time 2024/4/24 10:02
 */
@RestController
@RequestMapping("/techniqueMat")
@CrossOrigin
public class MatController {
    @Autowired
    private MatService matService;
    /**
     * 保存产品物料
     * @param techniqueMat
     * @return
     */
    @PostMapping("/saveMat")
    public QdResult saveMat(@RequestBody TechniqueMat techniqueMat){
        return matService.saveMat(techniqueMat);
    }
    /**
     * 更新产品物料
     * @param techniqueMat
     * @return
     */
    @PostMapping("/updateMat")
    public QdResult updateMat(@RequestBody TechniqueMat techniqueMat){
        return matService.updateMat(techniqueMat);
    }
    /**
     * 删除产品物料
     * @param matId
     * @return
     */
    @GetMapping("/delete")
    public QdResult deleteById(Long matId){
        return matService.deleteById(matId);
    }
    /**
     * 批量删除产品物料
     * @param matIds
     * @return
     */
    @GetMapping("/deletes")
    public QdResult deletes(Long [] matIds){
        return matService.deletes(matIds);
    }
    /**
     * 分页查询产品物料
     * @param techniqueMat
     * @param start
     * @param limit
     * @return
     */
    @GetMapping("/queryByPage")
    public QdResult<PagerDTO<TechniqueMat>> queryPager(TechniqueMat techniqueMat, @RequestParam(defaultValue = "1") int start, @RequestParam(defaultValue = "10") int limit){
        return matService.queryPager(techniqueMat,start,limit);
    }
    /**
     * 查询产品物料
     * @param matId
     * @return
     */
    @GetMapping("/queryById")
    public QdResult<TechniqueMat> queryById(Long matId){
        return matService.queryById(matId);
    }
}

